home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Programmer Power Tools
/
Programmer Power Tools.iso
/
tex
/
webtp55.arc
/
WEAVE.CHG
< prev
next >
Wrap
Text File
|
1989-12-01
|
26KB
|
793 lines
% This is WEAVE.CHG for TURBO Pascal 5.5
% (c) 1989 by Peter Sawatzki
%
% Change History:
%
% Initials: PS = Peter Sawatzki, FE617@DHAFEU11
% =========
%
% rel. date Author description
% ==== ==== ====== ===========
% v0.1 5-Mar-88 PS initial TP3 release
% v0.2 29-Jul-89 PS @i option: (nested) include files
%
%
% Tangle/Compile Instructions:
% ============================
% TANGLE WEAVE /d /m /c
% TPC /$A+,O-,E-,N-,B-,I-,V-,S-,D- /$M$5000,0,$2000 WEAVE
%
%
────────────────────────────────────────────────────────────────
@x l.72 m.1
@d banner=='This is WEAVE, Version 4'
@y
@d banner=='This is WEAVE, Version 4/TP55 0.2'
@z
────────────────────────────────────────────────────────────────
@x l.82 m.2
@d end_of_WEAVE = 9999 {go here to wrap it up}
@p @t\4@>@<Compiler directives@>@/
program WEAVE(@!web_file,@!change_file,@!tex_file);
label end_of_WEAVE; {go here to finish}
const @<Constants in the outer block@>@/
type @<Types in the outer block@>@/
var @<Globals in the outer block@>@/
@y
@p program WEAVE;
const @<Constants in the outer block@>@/
type @<Types in the outer block@>@/
const @<Typed constants in the outer block@>@/
var @<Globals in the outer block@>@/
@<Inline procedures and functions@>@/
@<All purpose procedures and functions@>@/
@z
────────────────────────────────────────────────────────────────
@x l.101 m.3
@d debug==@{ {change this to `$\\{debug}\equiv\null$' when debugging}
@d gubed==@t@>@} {change this to `$\\{gubed}\equiv\null$' when debugging}
@y
@d ifdef(#)==@={$ifdef @>#@=}@>
@d endif==@={$endif}@>
@d debug==ifdef(deb)
@d gubed==endif
@d Asm(#)==inline(@[#@])
@z
────────────────────────────────────────────────────────────────
@x l.106 m.3
@d stat==@{ {change this to `$\\{stat}\equiv\null$'
when gathering usage statistics}
@d tats==@t@>@} {change this to `$\\{tats}\equiv\null$'
when gathering usage statistics}
@y
@d stat==ifdef(sta)
@d tats==endif
@z
────────────────────────────────────────────────────────────────
@x l.121 m.4
@<Compiler directives@>=
@{@&$C-,A+,D-@} {no range check, catch arithmetic overflow, no debug overhead}
@!debug @{@&$C+,D+@}@+ gubed {but turn everything on when debugging}
@y
@<Inline proc...@>=
function mavail: word;
Asm(mov ah,$48/ {allocate memory}
mov bx,$FFFF/ {determine free memory}
int $21/
mov ax,bx); {return size of largest available block}
function malloc (no: word): word;
Asm(mov ah,$48/ {allocate memory}
pop bx/ {no of bytes}
int $21/
jnc ok/ {no error}
xor ax,ax/ {clear ax in case of error}
ok: );
procedure mfree (segm: word);
Asm(mov ah,$49/ {free memory}
pop es/ {segment to free}
int $21);
@z
────────────────────────────────────────────────────────────────
@x l.146 m.6
@d incr(#) == #:=#+1 {increase a variable by unity}
@d decr(#) == #:=#-1 {decrease a variable by unity}
@y
@d incr(#) == Inc(#) {increase a variable by unity}
@d decr(#) == Dec(#) {decrease a variable by unity}
@d integer == LongInt
@d void == begin end
@z
────────────────────────────────────────────────────────────────
@x l.172 m.7
@d othercases == others: {default for cases not listed explicitly}
@y
@d othercases == else {default for cases not listed explicitly}
@z
────────────────────────────────────────────────────────────────
@x l.181 m.8
@!max_bytes=45000; {|1/ww| times the number of bytes in identifiers,
index entries, and module names; must be less than 65536}
@!max_names=5000; {number of identifiers, index entries, and module names;
must be less than 10240}
@!max_modules=2000;{greater than the total number of modules}
@!hash_size=353; {should be prime}
@!buf_size=100; {maximum length of input line}
@!longest_name=400; {module names shouldn't be longer than this}
@!long_buf_size=500; {|buf_size+longest_name|}
@!line_length=80; {lines of \TeX\ output have at most this many characters,
should be less than 256}
@!max_refs=30000; {number of cross references; must be less than 65536}
@!max_toks=30000; {number of symbols in \PASCAL\ texts being parsed;
must be less than 65536}
@!max_texts=2000; {number of phrases in \PASCAL\ texts being parsed;
must be less than 10240}
@!max_scraps=1000; {number of tokens in \PASCAL\ texts being parsed}
@!stack_size=200; {number of simultaneous output levels}
@y
@!max_bytes=6400; {|1/ww| times the number of bytes in identifiers,
index entries, and module names; must be less than 65536}
@!max_names=5000; {number of identifiers, index entries, and module names;
must be less than 10240}
@!max_modules=2000;{greater than the total number of modules}
@!hash_size=353; {should be prime}
@!buf_size=100; {maximum length of input line}
@!longest_name=400; {module names shouldn't be longer than this}
@!long_buf_size=500; {|buf_size+longest_name|}
@!line_length=80; {lines of \TeX\ output have at most this many characters,
should be less than 256}
@!max_refs=32000; {number of cross references; must be less than 65536}
@!max_toks=32000; {number of symbols in \PASCAL\ texts being parsed;
must be less than 65536}
@!max_texts=3000; {number of phrases in \PASCAL\ texts being parsed;
must be less than 10240}
@!max_scraps=3000; {number of tokens in \PASCAL\ texts being parsed}
@!stack_size=300; {number of simultaneous output levels}
@z
────────────────────────────────────────────────────────────────
@x l.307 m.12
@!text_file=packed file of text_char;
@y
@!text_file=Text;
@z
────────────────────────────────────────────────────────────────
@x l.309 m.13
@ The \.{WEAVE} and \.{TANGLE} processors convert between ASCII code and
the user's external character set by means of arrays |xord| and |xchr|
that are analogous to \PASCAL's |ord| and |chr| functions.
@<Globals...@>=
@!xord: array [text_char] of ASCII_code;
{specifies conversion of input characters}
@!xchr: array [ASCII_code] of text_char;
{specifies conversion of output characters}
@ If we assume that every system using \.{WEB} is able to read and write the
visible characters of standard ASCII (although not necessarily using the
ASCII codes to represent them), the following assignment statements initialize
most of the |xchr| array properly, without needing any system-dependent
changes. For example, the statement \.{xchr[@@\'101]:=\'A\'} that appears
in the present \.{WEB} file might be encoded in, say, {\mc EBCDIC} code
on the external medium on which it resides, but \.{TANGLE} will convert from
this external code to ASCII and back again. Therefore the assignment
statement \.{XCHR[65]:=\'A\'} will appear in the corresponding \PASCAL\ file,
and \PASCAL\ will compile this statement so that |xchr[65]| receives the
character \.A in the external (|char|) code. Note that it would be quite
incorrect to say \.{xchr[@@\'101]:="A"}, because |"A"| is a constant of
type |integer|, not |char|, and because we have $|"A"|=65$ regardless of
the external character set.
@<Set init...@>=
xchr[@'40]:=' ';
xchr[@'41]:='!';
xchr[@'42]:='"';
xchr[@'43]:='#';
xchr[@'44]:='$';
xchr[@'45]:='%';
xchr[@'46]:='&';
xchr[@'47]:='''';@/
xchr[@'50]:='(';
xchr[@'51]:=')';
xchr[@'52]:='*';
xchr[@'53]:='+';
xchr[@'54]:=',';
xchr[@'55]:='-';
xchr[@'56]:='.';
xchr[@'57]:='/';@/
xchr[@'60]:='0';
xchr[@'61]:='1';
xchr[@'62]:='2';
xchr[@'63]:='3';
xchr[@'64]:='4';
xchr[@'65]:='5';
xchr[@'66]:='6';
xchr[@'67]:='7';@/
xchr[@'70]:='8';
xchr[@'71]:='9';
xchr[@'72]:=':';
xchr[@'73]:=';';
xchr[@'74]:='<';
xchr[@'75]:='=';
xchr[@'76]:='>';
xchr[@'77]:='?';@/
xchr[@'100]:='@@';
xchr[@'101]:='A';
xchr[@'102]:='B';
xchr[@'103]:='C';
xchr[@'104]:='D';
xchr[@'105]:='E';
xchr[@'106]:='F';
xchr[@'107]:='G';@/
xchr[@'110]:='H';
xchr[@'111]:='I';
xchr[@'112]:='J';
xchr[@'113]:='K';
xchr[@'114]:='L';
xchr[@'115]:='M';
xchr[@'116]:='N';
xchr[@'117]:='O';@/
xchr[@'120]:='P';
xchr[@'121]:='Q';
xchr[@'122]:='R';
xchr[@'123]:='S';
xchr[@'124]:='T';
xchr[@'125]:='U';
xchr[@'126]:='V';
xchr[@'127]:='W';@/
xchr[@'130]:='X';
xchr[@'131]:='Y';
xchr[@'132]:='Z';
xchr[@'133]:='[';
xchr[@'134]:='\';
xchr[@'135]:=']';
xchr[@'136]:='^';
xchr[@'137]:='_';@/
xchr[@'140]:='`';
xchr[@'141]:='a';
xchr[@'142]:='b';
xchr[@'143]:='c';
xchr[@'144]:='d';
xchr[@'145]:='e';
xchr[@'146]:='f';
xchr[@'147]:='g';@/
xchr[@'150]:='h';
xchr[@'151]:='i';
xchr[@'152]:='j';
xchr[@'153]:='k';
xchr[@'154]:='l';
xchr[@'155]:='m';
xchr[@'156]:='n';
xchr[@'157]:='o';@/
xchr[@'160]:='p';
xchr[@'161]:='q';
xchr[@'162]:='r';
xchr[@'163]:='s';
xchr[@'164]:='t';
xchr[@'165]:='u';
xchr[@'166]:='v';
xchr[@'167]:='w';@/
xchr[@'170]:='x';
xchr[@'171]:='y';
xchr[@'172]:='z';
xchr[@'173]:='{';
xchr[@'174]:='|';
xchr[@'175]:='}';
xchr[@'176]:='~';@/
xchr[0]:=' '; xchr[@'177]:=' '; {these ASCII codes are not used}
@y
@ The \.{WEAVE} and \.{TANGLE} processors convert between ASCII code and
the user's external character set by means of arrays |xord| and |xchr|
that are analogous to \PASCAL's |ord| and |chr| functions.
The following typed constants define the |xchr| array properly.
@<Typed constants...@>=
xchr: array [ASCII_code] of text_char=(@/
' ',' ',' ',' ',' ',' ',' ',' ', ' ', #9,' ',' ',' ',#13,' ',' ',@/
' ',' ',' ',' ',' ',' ',' ',' ', ' ',' ',' ',' ',' ',' ',' ',' ',@/
' ','!','"','#','$','%','&','''', '(',')','*','+',',','-','.','/',@/
'0','1','2','3','4','5','6','7', '8','9',':',';','<','=','>','?',@/
'@@','A','B','C','D','E','F','G', 'H','I','J','K','L','M','N','O',@/
'P','Q','R','S','T','U','V','W', 'X','Y','Z','[','\',']','^','_',@/
'`','a','b','c','d','e','f','g', 'h','i','j','k','l','m','n','o',@/
'p','q','r','s','t','u','v','w', 'x','y','z','{','|','}','~',' ',@/
' ',' ',' ',' ',' ',' ',' ',' ', ' ',' ',' ',' ',' ',' ',' ',' ',@/
' ',' ',' ',' ',' ',' ',' ',' ', ' ',' ',' ',' ',' ',' ',' ',' ',@/
' ',' ',' ',' ',' ',' ',' ',' ', ' ',' ',' ',' ',' ',' ',' ',' ',@/
' ',' ',' ',' ',' ',' ',' ',' ', ' ',' ',' ',' ',' ',' ',' ',' ',@/
' ',' ',' ',' ',' ',' ',' ',' ', ' ',' ',' ',' ',' ',' ',' ',' ',@/
' ',' ',' ',' ',' ',' ',' ',' ', ' ',' ',' ',' ',' ',' ',' ',' ',@/
' ',' ',' ',' ',' ',' ',' ',' ', ' ',' ',' ',' ',' ',' ',' ',' ',@/
' ',' ',' ',' ',' ',' ',' ',' ', ' ',' ',' ',' ',' ',' ',' ',' ');
@ The following definition makes the |xord| array contain a
suitable inverse to the information in |xchr|.
@<Globals...@>=
@!xord: array [text_char] of ASCII_code absolute xchr;
{specifies conversion of input characters}
@z
────────────────────────────────────────────────────────────────
@x l.449 m.16
@ When we initialize the |xord| array and the remaining parts of |xchr|,
it will be convenient to make use of an index variable, |i|.
@<Local variables for init...@>=
@!i:0..255;
@ Here now is the system-dependent part of the character set.
If \.{WEB} is being implemented on a garden-variety \PASCAL\ for which
only standard ASCII codes will appear in the input and output files, you
don't need to make any changes here. But if you have, for example, an extended
character set like the one in Appendix~C of {\sl The \TeX book}, the first
line of code in this module should be changed to
$$\hbox{|for i:=1 to @'37 do xchr[i]:=chr(i);|}$$
\.{WEB}'s character set is essentially identical to \TeX's, even with respect to
characters less than @'40.
@^system dependencies@>
Changes to the present module will make \.{WEB} more friendly on computers
that have an extended character set, so that one can type things like
\.^^Z\ instead of \.{<>}. If you have an extended set of characters that
are easily incorporated into text files, you can assign codes arbitrarily
here, giving an |xchr| equivalent to whatever characters the users of
\.{WEB} are allowed to have in their input files, provided that unsuitable
characters do not correspond to special codes like |carriage_return|
that are listed above.
(The present file \.{WEAVE.WEB} does not contain any of the non-ASCII
characters, because it is intended to be used with all implementations of
\.{WEB}. It was originally created on a Stanford system that has a
convenient extended character set, then ``sanitized'' by applying another
program that transliterated all of the non-standard characters into
standard equivalents.)
@<Set init...@>=
for i:=1 to @'37 do xchr[i]:=' ';
for i:=@'200 to @'377 do xchr[i]:=' ';
@ The following system-independent code makes the |xord| array contain a
suitable inverse to the information in |xchr|.
@<Set init...@>=
for i:=first_text_char to last_text_char do xord[chr(i)]:=" ";
for i:=1 to @'377 do xord[xchr[i]]:=i;
xord[' ']:=" ";
@y
@ not neccesssary
@ not neccessary
@ not neccessary
@z
────────────────────────────────────────────────────────────────
@x l.517 m.20
@!term_out:text_file; {the terminal as an output file}
@y
@ @d term_out==Output
@z
────────────────────────────────────────────────────────────────
@x l.525 m.21
rewrite(term_out,'TTY:'); {send |term_out| output to the terminal}
@y
@z
────────────────────────────────────────────────────────────────
@x l.532 m.22
@d update_terminal == break(term_out) {empty the terminal output buffer}
@y
@d update_terminal ==
@z
────────────────────────────────────────────────────────────────
@x l.534 m.23
@ The main input comes from |web_file|; this input may be overridden
by changes in |change_file|. (If |change_file| is empty, there are no changes.)
@<Globals...@>=
@!web_file:text_file; {primary input}
@!change_file:text_file; {updates}
@y
@ We need some data structures to implement the include facility of
\.{TANGLE}
@<Constants...@>=
No_of_Files = 5; {Webfile + Changefile + all Include files}
buffer_size = 4*1024; {multiple of 16}
@ @<Globals...@>=
FileMax: 0..No_of_Files; {how many files fit into memory}
@!file_prev: array[1..No_of_Files] of word;
@!file_ptr: array[1..No_of_Files] of word;
@ To access a textfile we use
@d textf(#)==Text(Ptr(file_ptr[#],0)^)
@ The main input comes from |web_file|; this input may be overridden
by changes in |change_file|. (If |change_file| is empty, there are no changes.)
@<Globals...@>=
@!web_file:word; {primary input}
@!change_file:word; {updates}
@z
────────────────────────────────────────────────────────────────
@x l.541 m.24
@ The following code opens the input files. Since these files were listed
in the program header, we assume that the \PASCAL\ runtime system has
already checked that suitable file names have been given; therefore no
additional error checking needs to be done. We will see below that
\.{WEAVE} reads through the entire input twice.
@^system dependencies@>
@p procedure open_input; {prepare to read |web_file| and |change_file|}
begin reset(web_file); reset(change_file);
end;
@y
@ The following code closes an input file. If the input file is the son
of another input file, the higher level file is returned.
@^system dependencies@>
@p procedure close_fil (var f: word);
var tf: word;
begin
if f<>0 then begin
Close(textf(f));
if IoResult<>0 then void;
tf:= f;
f:= file_prev[f];
file_prev[tf]:= 0; { buffer now available }
if f=$FFFF then f:= 0;
end
end;
@ Next we need a function to open an input file. Checks will be
made to verify that there are not too many include files open.
@p function open_fil (var f: word; name: String): boolean;
var
tf: word;
begin
open_fil:= false;
tf:= 1;
while (tf<=FileMax) and (file_prev[tf]<>0) do
Inc(tf);
if tf>FileMax then
fatal_halt('@@i ',name,': no more than ',FileMax,' open files.');
assign(textf(tf),name);
SetTextBuf(textf(tf),Ptr(file_ptr[tf],128)^,buffer_size);
reset(textf(tf));
if IoResult=0 then begin
open_fil:= true;
if f=0 then f:= $FFFF;
file_prev[tf]:= f;
f:= tf
end
end;
@ @<Close all Files@>=
while web_file>0 do close_fil(web_file);
while change_file>0 do close_fil(change_file);
@ The following code initializes the input buffers
@<Local variables for init...@>=
tf: word;
@ @<Set init...@>=
FileMax:= No_of_Files;
repeat
file_ptr[1]:= malloc(((buffer_size+128) shr 4) *FileMax);
if file_ptr[1]=0 then decr(FileMax)
until (file_ptr[1]<>0) or (FileMax<2);
if file_ptr[1]=0 then
fatal_halt('No memory for the webfile and a changefile.');
tf:= 2;
while tf<=No_of_Files do begin
file_ptr[tf]:= file_ptr[tf-1]+(buffer_size+128) shr 4;
incr(tf)
end;
@ We need a procedure to force the extension in a filename.
@<Inline proc...@>=
function ForceExtension (FName, FExt : String): String;
{-Return a pathname with the specified extension attached}
var
i,DotPos,BackSlashPos: byte;
begin
DotPos := 0;
for i := 1 to _Length(FName) do begin
if FName[I]='.' then DotPos := i;
if FName[i]='\' then BackSlashPos:= i;
end;
if DotPos>BackSlashPos then
ForceExtension:= _copy(FName,1,DotPos)+FExt
else
ForceExtension := FName+'.'+FExt;
end;
@ Now we open the |web_file| and a |change_file| if present.
@p procedure open_input; {prepare to read |web_file| and |change_file|}
var
fn: String;
tf: word;
begin
for tf:= 1 to No_of_Files do
file_prev[tf]:= 0;
web_file:= 0;
change_file:= 0;
if not open_fil(web_file,Parameter(1)) then
if not open_fil(web_file,ForceExtension(Parameter(1),'WEB')) then
fatal_halt('WEB file not found');
fn:= Parameter(2); if fn='' then fn:= Parameter(1);
if not open_fil(change_file,fn) then
if not open_fil(change_file,ForceExtension(fn,'CHG')) then
void;
end;
@z
────────────────────────────────────────────────────────────────
@x l.554 m.25
@<Globals...@>=
@!tex_file: text_file;
@y
@<Globals...@>=
@!tex_file: text_file;
@!tex_buffer: word;
@z
────────────────────────────────────────────────────────────────
@x l.563 m.26
@<Set init...@>=
rewrite(tex_file);
@y
@<Close all...@>=
@!Close(tex_file);
@
@<Set init...@>=
tex_buffer:= malloc(8192 shr 4);
assign(tex_file,ForceExtension(ParamStr(1),'TEX'));
SetTextBuf(tex_file,Ptr(tex_buffer,0)^,8192);
rewrite(tex_file);
if IoResult>0 then fatal_halt('Unable to create ',ForceExtension(ParamStr(1),'TEX'));
@z
────────────────────────────────────────────────────────────────
@x l.586 m.28
@p function input_ln(var f:text_file):boolean;
{inputs a line or returns |false|}
var final_limit:0..buf_size; {|limit| without trailing blanks}
begin limit:=0; final_limit:=0;
if eof(f) then input_ln:=false
else begin while not eoln(f) do
begin buffer[limit]:=xord[f^]; get(f);
incr(limit);
if buffer[limit-1]<>" " then final_limit:=limit;
if limit=buf_size then
begin while not eoln(f) do get(f);
decr(limit); {keep |buffer[buf_size]| empty}
if final_limit>limit then final_limit:=limit;
print_nl('! Input line too long'); loc:=0; error;
@.Input line too long@>
end;
end;
read_ln(f); limit:=final_limit; input_ln:=true;
end;
end;
@y
@p function input_ln (var f: word):boolean;
label
new_file;
var
s: String;
fileend: boolean;
i: byte;
procedure open_include;
var
i: byte;
fn: String;
begin
i:= 4;
while (i<=Length(s)) and (s[i]<>' ') do incr(i);
byte(fn[0]):= i-4;
move(s[4],fn[1],Length(fn));
if not open_fil(f,fn) then
if not open_fil(f,fn+'.CHI') then
if not open_fil(f,fn+'.CHG') then
fatal_halt('@@i ',fn,': Include file not found.')
end;
begin new_file:
limit:= 0;
fileend:= eof(textf(f));
if IoResult>0 then fileend:= true;
if fileend then begin
close_fil(f);
if f>0 then
goto new_file
else
input_ln:= false
end else begin
readln(textf(f),s);
limit:= byte(s[0]);
if (limit>3) and (s[1]='@@') and (s[2]='i') and (s[3]=' ') then begin
open_include;
goto new_file
end;
while (limit>0) and (s[limit]=' ') do decr(limit);
for i:= 1 to limit do buffer[i-1]:= xord[s[i]];
input_ln:=true;
end;
end;
@z
────────────────────────────────────────────────────────────────
@x l.684 m.33
@d fatal_error(#)==begin new_line; print(#); error; mark_fatal; jump_out;
end
@<Error handling...@>=
procedure jump_out;
begin goto end_of_WEAVE;
end;
@y
@d fatal_error(#)==begin new_line; print(#); error; mark_fatal; Halt(history) end
@d fatal_halt(#)==begin new_line; print(#); mark_fatal; Halt(history) end
@z
────────────────────────────────────────────────────────────────
@x l.729 m.37
@d ww=2 {we multiply the byte capacity by approximately this amount}
@y
@d ww=16
@z
────────────────────────────────────────────────────────────────
@x l.731 m.37
@<Globals...@>=
@!byte_mem: packed array [0..ww-1,0..max_bytes] of ASCII_code;
{characters of names}
@y
@ @<Set init...@>=
if (ww<>16) then
fatal_halt('! ww must be 16 (segment size).');
byte_seg:= malloc(max_bytes+1);
@ @<Inline...@>=
function bytem (s,o: word): Pointer;@/
Asm(pop dx/
pop ax/
add dx,[>byte_seg]);
@ @d byte_mem[#]==ASCII_code(bytem(#)^)
@ @<Globals...@>=
@t\hskip1em@>@!byte_seg: word;
@z
────────────────────────────────────────────────────────────────
@x l.737 m.37
@!xref: array [0..max_names] of sixteen_bits; {heads of cross-reference lists}
@y
@ @<Set init...@>=
xref_base:= Ptr(malloc(sizeof(xref_ar) shr 4 +1),0);
@ @d xref==xref_base^
@ @<Types...@>=
@!xref_ar= array [0..max_names] of sixteen_bits; {heads of cross-reference lists}
@ @<Globals...@>=
@t\hskip1em@>@!xref_base: ^xref_ar;
@z
────────────────────────────────────────────────────────────────
@x l.883 m.46
@d num(#)==xmem[#].num_field
@d xlink(#)==xmem[#].xlink_field
@y
@d num(#)==xm_num_field^[#]
@d xlink(#)==xm_link_field^[#]
@z
────────────────────────────────────────────────────────────────
@x l.890 m.48
@ @<Globals...@>=
@!xmem:array[xref_number] of packed record@t@>@/
@!num_field: sixteen_bits; {module number plus zero or |def_flag|}
@!xlink_field: sixteen_bits; {pointer to the previous cross reference}
end;
@y
@ @<Set init...@>=
xm_link_field:= Ptr(malloc(sizeof(xmem_ar) shr 4 +1),0);
xm_num_field := Ptr(malloc(sizeof(xmem_ar) shr 4 +1),0);
@ @<Types...@>=
@!xmem_ar=array[xref_number] of sixteen_bits;
@ @<Globals...@>=
@!xm_link_field: ^xmem_ar;
@!xm_num_field: ^xmem_ar;
@z
────────────────────────────────────────────────────────────────
@x l.965 m.53
@t\hskip1em@>@!tok_mem: packed array [0..max_toks] of sixteen_bits; {tokens}
@y
@ @<Set init...@>=
tok_base:= Ptr(malloc(sizeof(tok_ar) shr 4 +1),0);
@ @d tok_mem==tok_base^
@ @<Types...@>=
@!tok_ar= array [0..max_toks] of sixteen_bits; {tokens}
@ @<Globals...@>=
@t\hskip1em@>@!tok_base: ^tok_ar;
@z
────────────────────────────────────────────────────────────────
@x l.1711 m.97
@d up_to(#)==#-24,#-23,#-22,#-21,#-20,#-19,#-18,#-17,#-16,#-15,#-14,
#-13,#-12,#-11,#-10,#-9,#-8,#-7,#-6,#-5,#-4,#-3,#-2,#-1,#
@y
@z
────────────────────────────────────────────────────────────────
@x l.1729 m.97
"A",up_to("Z"),"a",up_to("z"): @<Get an identifier@>;
@y
"A".."Z","a".."z": @<Get an identifier@>;
"$": scanning_hex:= true;
@z
────────────────────────────────────────────────────────────────
@x l.4805 m.267
begin initialize; {beginning of the main program}
@y
@ @<Globals...@>=
@!ExitSave: Pointer;
@ @p
@={$F+}@>
procedure FinishUp;
@={$F-}@>
begin
if ErrorAddr<>NIL then begin
write_ln('Internal error #',ExitCode);
ErrorAddr:= NIL;
Halt(ExitCode)
end;
stat @<Print statistics about memory usage@>;@+tats@;@/
@<Print the job |history|@>;
@<Close all Files@>;
ExitProc:= ExitSave;
end; { FinishUp }
begin { main }
ExitSave:= ExitProc;
ExitProc:= @@FinishUp;
if (ParamCount=0) then begin
print_ln(banner);
print_ln('Usage: WEAVE <WEB file> [<CHG file>]');
print_ln('');
Halt(history)
end;
initialize;
@z
────────────────────────────────────────────────────────────────
@x l.4811 m.267
end_of_WEAVE:
stat @<Print statistics about memory usage@>;@+tats@;@/
@t\4\4@>{here files should be closed if the operating system requires it}
@<Print the job |history|@>;
@y
{ exit via Unit WebExit (UNIT WebStuff) }
@z
────────────────────────────────────────────────────────────────
@x l.4847 m.270
itself will get a new module number.
@^system dependencies@>
@y
itself will get a new module number.
@^system dependencies@>
Here we add the more extensive changes for this \.{TP} version
of \.{WEAVE}.
@ The following function returns a commandline parameter without
an option
@<All purpose procedures and functions@>=
function Parameter (i: word): String;
var
p: word;
s: String;
begin
s:= ParamStr(i);
p:= pos('-',s);
if p=0 then p:= pos('/',s);
if p>0 then byte(s[0]):= p-1;
Parameter:= s
end;
@ temporary
@<Typed constants...@>=
octconv: boolean = false;
@z